<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>骡窝窝系统管理平台</title>
    <#include "../common/header.ftl"/>
    <script src="/js/common.js"></script>
</head>
<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "travel" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>游记管理</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/travel/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>

                    <div class="form-group">
                        <label>关键字</label>
                        <input class="form-control" type="text" name="keyword" value="${(qo.keyword)!}">
                    </div>
                    <div class="form-group">
                        <select  class="form-control"  id="stateBtn" name="state" value="${(qo.state)!}">
                            <option value="1">待发布</option>
                            <option value="-1">已拒绝</option>
                            <option value="-2">全部</option>
                        </select>
                        <script>
                            $("#stateBtn").val(${(qo.state)!});
                        </script>
                    </div>
                    <button id="btn_query" class="btn btn-default">
                        <span class="glyphicon glyphicon-search"></span> 查询
                    </button>
                </form>
            </div>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>标题</th>
                        <th>封面</th>
                        <th>地点</th>
                        <th>作者</th>
                        <th>状态</th>
                    </tr>
                    </thead>
                    <tbody>
					<#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index+1}</td>
                        <td>${entity.title}</td>
                        <td><img src='${entity.coverUrl}' width="30px"/></td>
                        <td>${entity.place.name}</td>
                        <td>${entity.author.nickName}</td>
                        <td>${entity.stateName}</td>
                        <td>
                            <a href="javascript:void(0);" class="changeStateBtn" data-state="2" data-did="${entity.id}">发布</a>
                        </td>
                        <td>
                            <a href="javascript:void(0);" class="changeStateBtn" data-state="-1" data-did="${entity.id}">拒绝</a>
                        </td>
                        <td>
                            <a href="javascript:void(0);" class="lookBtn" data-did="${entity.id}">查看文章</a>
                        </td>
                    </tr>
					</#list>
                    </tbody>
                </table>

              <#include "../common/page.ftl"/>
            </div>
        </div>
    </div>
</div>
<#--模态框-->
<div class="modal fade" id="travelContentModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        <#--模态框头部-->
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">查看文章</h4>
            </div>
        <#--模态框正文-->
            <div class="modal-body">
            </div>
        <#--模态框底部-->
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {
        //将文章内容显示在模态框中
        $(".lookBtn").click(function () {
            //获取自定义属性的值
            var id=$(this).data("did");
            //发送异步请求去获取文章内容
            $.get("/travel/getContentById.do",{id:id},function (data) {
                console.log(data);
                //给模态框内容赋值
                $("#travelContentModal .modal-body").html(data.content);
            });
            $("#travelContentModal").modal("show");
        });
        //发布/拒绝功能
        $(".changeStateBtn").click(function () {
            //获取自定义属性
            var id=$(this).data("did");
            var state=$(this).data("state");
            //发送异步请求去修改状态
            $.post("/travel/changeState.do",{id:id,state:state},function (data) {
                doSuccess();
            });
        })
    });
</script>
<style>
    #travelContentModal img {
        width: 100%;
    }
    #travelContentModal .modal-body {
        max-height: 600px;
        overflow-y: scroll;
    }

</style>
</body>
</html>